import { ListItemType } from "../../views/home";
export const ADD_CAR_ITEM_COUNT = "ADD_CAR_ITEM_COUNT";
export const SUB_CAR_ITEM_COUNT = "SUB_CAR_ITEM_COUNT";
export const DELETE_CAR_ITEM = "DELETE_CAR_ITEM";
export const ADD_CAR_ITEM = "ADD_CAR_ITEM";
export const SIWTCH_CAR_ITEM_IS_CEHCKED = "SIWTCH_CAR_ITEM_IS_CEHCKED";
export const SIWTCH_ALL_IS_CHECKED = "SIWTCH_ALL_IS_CHECKED";

interface SwitchAllISCheckedType {
  type: typeof SIWTCH_ALL_IS_CHECKED;
  payload: boolean;
}

export function switchAllISCheckedActionCreator(
  payload: boolean
): SwitchAllISCheckedType {
  return { type: SIWTCH_ALL_IS_CHECKED, payload };
}

interface SwitchCarItemIsCheckedType {
  type: typeof SIWTCH_CAR_ITEM_IS_CEHCKED;
  payload: string;
}

export function switchCarItemIsCheckedActionCreator(
  payload: string
): SwitchCarItemIsCheckedType {
  return { type: SIWTCH_CAR_ITEM_IS_CEHCKED, payload };
}

interface AddCarItemType {
  type: typeof ADD_CAR_ITEM;
  payload: ListItemType;
}

export function addCarItemActionCreator(payload: ListItemType): AddCarItemType {
  return { type: ADD_CAR_ITEM, payload };
}

interface AddCarItemCountType {
  type: typeof ADD_CAR_ITEM_COUNT;
  payload: string;
}

export function addCarItemCountActionCreator(
  payload: string
): AddCarItemCountType {
  return { type: ADD_CAR_ITEM_COUNT, payload };
}

interface SubCarItemCountType {
  type: typeof SUB_CAR_ITEM_COUNT;
  payload: string;
}

export function subCarItemCountActionCreator(
  payload: string
): SubCarItemCountType {
  return { type: SUB_CAR_ITEM_COUNT, payload };
}

interface DeleteCarItemType {
  type: typeof DELETE_CAR_ITEM;
  payload: string;
}

export function DeleteCarItemActionCreator(payload: string): DeleteCarItemType {
  return { type: DELETE_CAR_ITEM, payload };
}

export type CarActions =
  | AddCarItemType
  | AddCarItemCountType
  | SubCarItemCountType
  | DeleteCarItemType
  | SwitchCarItemIsCheckedType
  | SwitchAllISCheckedType;
